package com.bjc.platform.dao;

import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;

import org.springframework.data.domain.Pageable;

public interface GenericDao {
	
	public EntityManager getEntityManager();

	/**
	 * query by native sql
	 * 
	 * @param sql
	 * @param params
	 * @param pager
	 * @return
	 */
	public List<?> queryBySql(String sql, Map<String, Object> params,
			Pageable pager);

	/**
	 * query by native sql
	 * 
	 * @param sql
	 * @param params
	 * @param pager
	 * @return
	 */
	public List<?> queryBySql(String sql, Object[] params, Pageable pager);

	/**
	 * query by JP QL
	 * 
	 * @param jpql
	 * @param params
	 * @param pager
	 * @return
	 */
	public List<?> queryByJpql(String jpql, Map<String, Object> params,
			Pageable pager);

	/**
	 * query by JP QL
	 * 
	 * @param jpql
	 * @param params
	 * @param pager
	 * @return
	 */
	public List<?> queryByJpql(String jpql, Object[] params, Pageable pager);

	/**
	 * count by native sql
	 * 
	 * @param sql
	 * @param params
	 * @return
	 */
	public long countBySql(String sql, Map<String, Object> params);

	/**
	 * count by native sql
	 * 
	 * @param sql
	 * @param params
	 * @return
	 */
	public long countBySql(String sql, Object[] params);

	/**
	 * count by JP QL
	 * 
	 * @param sql
	 * @param params
	 * @return
	 */
	public long countByJpql(String jpql, Map<String, Object> params);

	/**
	 * count by JP QL
	 * 
	 * @param sql
	 * @param params
	 * @return
	 */
	public long countByJpql(String jpql, Object[] params);

	/**
	 * 通过查询SQL语句返回结果的Map集合
	 * 
	 * @param sql
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryBySqlToMap(String sql, Object[] params);	
	public List<Map<String, Object>> queryBySqlToMap(String sql, Object[] params,Pageable pager);
	
	/**
	 * 通过查询SQL语句返回结果的Map集合
	 * 
	 * @param sql
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> queryBySqlToMap(String sql, Map<String, Object> params);
	public List<Map<String, Object>> queryBySqlToMap(String sql, Map<String, Object> params,Pageable pager);

	/**
	 * 执行Sql语句
	 * 
	 * @param string
	 * @param objects
	 */
	public void executeSql(String string, Object[] objects);

	/**查询 SQL语句返回List结果集合
	 * @param sql
	 * @return
	 */
	public List<Object> queryBySql(String sql, Object[] objects);

	/**查询 SQL语句返回单条记录
	 * @param sql
	 * @return
	 */
	public Object queryOneBySql(String sql, Map<String, Object> params);
}
